import { number } from "echarts";
import instacne from "../request";
import type { Ref } from "vue"

interface IGoodsListParams {
    id?: number | Ref<string>
    parentId?: string | Ref<string>
    keyword?: string | Ref<string>;
    pageNum?: number | Ref<number>;
    pageSize?: number | Ref<number>;
}

interface IGoodsfenleiListItem {
    description: string;
    icon: string;
    id: number;
    keywords: string;
    level: number;
    name: string;
    navStatus: number;
    parentId: number;
    productCount: number;
    productUnit: string;
    showStatus: number;
    sort: number;
}

interface IGoodsfenleiListRes {
    [x: string]: any;
    list: IGoodsfenleiListItem[];
    productAttributeList: any[]
    name: string
    pageNum: number;
    pageSize: number;
    total: number;
    totalPage: number;
}
interface IupdatenavParams {
    ids?: number | number[];
    navStatus?: number;
    showStatus?: number

}
//添加分类接口
interface IaddproductCategory {
    id?: string | string[]
    description?: string;
    icon?: string;
    keywords?: string;
    name: string;
    navStatus?: number;
    parentId?: number;
    productAttributeIdList?: number | number[],
    productUnit?: string;
    showStatus?: number;
    sort?: number;
}
//品牌显示隐场参数
interface IupdateFactoryStatus {
    newStatus?: number;
    publishStatus?: number;
    recommendStatus?: number;
    factoryStatus?: number | number[];
    showStatus?: number | number[];
    ids: number | number[]
}
//所有商品请求的类型接口
interface IProductListParams {
    keyword?: string | string[];
    productSn?: string | string[];
    productCategoryId?: number;
    brandId?: number;
    publishStatus?: number;
    verifyStatus?: null
    pageNum?: number;
    pageSize?: number;
}
//所有商品响应的数据类型接口
interface IIProductListItem {
    albumPics: string;
    brandId: number,
    brandName: string;
    deleteStatus: number;
    description: string;
    detailDesc: string;
    detailHtml: string;
    detailMobileHtml: string;
    detailTitle: string;
    feightTemplateId: number;
    giftGrowth: number;
    giftPoint: number;
    id: number;
    keywords: string;
    lowStock: number;
    name: string;
    newStatus: number;
    note: string;
    originalPrice: number;
    pic: string;
    previewStatus: number;
    price: number,
    productAttributeCategoryId: number;
    productCategoryId: number;
    productCategoryName: string;
    productSn: string;
    promotionEndTime: string;
    promotionPerLimit: number;
    promotionPrice: number;
    promotionStartTime: string;
    promotionType: number;
    publishStatus: number;
    recommandStatus: number;
    sale: number;
    serviceIds: string;
    sort: number;
    stock: number;
    subTitle: string;
    unit: string;
    usePointLimit: number;
    verifyStatus: number;
    weight: number;
}
interface IProductList {
    list: IIProductListItem[],
    pageNum: number;
    pageSize: number
    total: number;
    totalPage: number;
}
//商品分类信息响应接口
interface IPromisproductCategory {
    description: string;
    icon: string;
    id: number;
    keywords: string;
    productAttributeIdList: any;
    name: string;
    navStatus: number;
    parentId: number;
    Parentclassification: any;
    productUnit: string;
    showStatus: number;
    sort: number;
}
//添加商品接口
interface IAddCreateParams {
    bigPic?: string;
    brandStory?: string;
    factoryStatus?: number;
    firstLetter?: string;
    logo: string;
    name: string;
    showStatus?: number;
    sort?: number;
}
//品牌响应接口

interface IBrandPromies {
    bigPic: string;
    brandStory: string;
    factoryStatus: number;
    firstLetter: string;
    id: number;
    logo: string;
    name: string;
    productCommentCount: number;
    productCount: number;
    showStatus: number;
    sort: number;
}

//添加商品参数类型约束
interface IaddProduct {
    albumPics?: string;
    brandId?: number;
    brandName?: string;
    deleteStatus?:number;
    description?: string;
    detailDesc?: string;
    detailHtml?: string;
    detailMobileHtml?: string;
    detailTitle?: string;
    feightTemplateId?: number;
    giftGrowth?: number;
    giftPoint?: number;
    id?: number;
    keywords?: string;
    lowStock?: number;
    memberPriceList?: [
        {
            id?: number;
            memberLevelId?: number;
            memberLevelName?: string;
            memberPrice?: number;
            productId?: number;
        }
    ],
    ame?: string;
    newStatus?: number;
    note?: string;
    originalPricenumber?:number;
    pic?: string;
    prefrenceAreaProductRelationList?: [
        {
            id?:number;
            prefrenceAreaId?: number;
            productId?: number;
        }
    ],
    previewStatus?: number;
    price?: number;
    productAttributeCategoryId?: number;
    productAttributeValueList?: [
        {
            id?: number;
            productAttributeId?: number;
            productId?: number;
            value?: string;
        }
    ],
    productCategoryId?:number
    productCategoryName?: string
    productFullReductionList?: [
        {
            fullPrice?: number;
            id?: number;
            productId?: number;
            reducePrice?: number;
        }
    ],
    productLadderList: [
        {
            count?: number;
            discount?: number;
            id?: number;
            price?: number;
            productId?: number;
        }
    ],
    productSn?: string;
    promotionEndTime?:string;
    promotionPerLimit?: number;
    promotionPrice?: number;
    promotionStartTime?: string;
    promotionType?: number;
    publishStatus?: number;
    recommandStatus?: number;
    sale?: number;
    serviceIds?: string,
    skuStockList?: [
        {
            id?: number;
            lockStock?: number;
            lowStock?: number;
            pic?: string;
            price?: number;
            productId?: number;
            promotionPrice?: number;
            sale?: number;
            skuCode?: string;
            spData?: string;
            stock?: number;
        }
    ],
    sort?:number;
    stock?:number;
    subTitle?: string;
    subjectProductRelationList?: [
        {
            id?: number;
            productId?:number;
            subjectId?:number;
        }
    ],
    unit?: string;
    usePointLimit?: number;
    verifyStatus?: number;
    weight?: number;
}
//属性列表接口
interface IBrandListParams {
    brandName?: string | Ref<string>;
    pageNum?: number | Ref<number>;
    pageSize?: number | Ref<number>;
    recommendStatus?: number | Ref<number>;
  }
  //响应数据接口
  interface IBrandListItem {
    brandId: number;
    brandName: string;
    id: number;
    recommendStatus: number;
    sort: number;
    attributeCount?: number;
    paramCount?: number;
    name?: string;
  }
  interface IBrandListRes {
    list: IBrandListItem[];
    pageNum: number;
    pageSize: number;
    total: number;
    totalPage: number;
  }
//所有商品一级分类 productCategory/list/withChildren
const GoodsfenleiList = (data: IGoodsListParams): Promise<IGoodsfenleiListRes> => {
    return instacne.get(`productCategory/list/${data.parentId ? data.parentId : 0}`, {
        params: data,
    })
}
//品牌列表 /brand/list
const GoodsBrandList = (data: IGoodsListParams): Promise<IGoodsfenleiListRes> => {
    return instacne.get('/brand/list', {
        params: data,
    })
}
//根据id获取商品品牌信息 brand/{id}
const updateBrand = (data: string | string[]): Promise<IPromisproductCategory> => {
    return instacne.get(`/brand/${data}`)
}
// productAttribute/category/list分页获取所有商品属性分类
const GoodscategoryList = (data: IGoodsListParams): Promise<IGoodsfenleiListRes> => {
    return instacne.get('productAttribute/category/list', {
        params: data,
    })
}
//筛选属性接口 productAttribute/category/list/withAttr
const GoodswithAttrList = (): Promise<IGoodsfenleiListRes[]> => {
    return instacne.get('productAttribute/category/list/withAttr')
}
//productCategory/delete/{id}删除商品分类
const GoodsDletefenleiList = (data: IGoodsListParams) => {
    return instacne.post(`productCategory/delete/${data.id}`)
}
//brand/delete/{id}删除品牌
const GoodsDleteBrandList = (data: IGoodsListParams) => {
    return instacne.get(`brand/delete/${data.id}`)
}
//productAttribute/category/delete/id 删除属性
const GoodsDletecategoryList = (data: IGoodsListParams) => {
    return instacne.get(`productAttribute/category/delete/${data.id}`)
}
//productCategory/list/withChildren所有一级分类及其子类
const GoodswithChildrenList = () => {
    return instacne.get('productCategory/list/withChildren')
}
// productCategory/update/navStatus 商品分类的显示隐藏ids: 94 navStatus: 0
const updatenavStatus = (data: IupdatenavParams) => {
    return instacne.post(`productCategory/update/navStatus?ids=${data.ids}&navStatus=${data.navStatus}`)
}
// productCategory/update/showStatus修改显示状态
const updatenavShowStatus = (data: IupdatenavParams) => {
    return instacne.post(`productCategory/update/showStatus?ids=${data.ids}&showStatus=${data.showStatus}`)
}
//productCategory/create添加产品分类
const addproductCategory = (data: IaddproductCategory) => {
    return instacne.post(`productCategory/create`, data)
}
//productCategory/update/{id}修改商品分类
const updateproductCategory = (data: IaddproductCategory) => {
    return instacne.post(`productCategory/update/${data.id}`, data)
}
//brand/update/factoryStatus批量更新厂家制造商状态
const updateFactoryStatus = (data: IupdateFactoryStatus) => {
    return instacne.post(`brand/update/factoryStatus?ids=${data.ids}&factoryStatus=${data.factoryStatus}`)
}
//brand/update/showStatus批量更新显示状态
const brandupdateshowStatus = (data: IupdateFactoryStatus) => {
    return instacne.post(`brand/update/showStatus?ids=${data.ids}&showStatus=${data.showStatus}`)
}
//product/list查询商品
const ProductList = (data: IProductListParams): Promise<IProductList> => {
    return instacne.get('product/list', {
        params: data
    })
}
//删除商品product/update/deleteStatus?ids=1337&deleteStatus=1
const DeleteProduct = (data: IupdatenavParams) => {
    return instacne.post(`product/update/deleteStatus?ids=${data.ids}&deleteStatus=1`)
}
//修改上架状态product/update/publishStatus
const UpdatePublishStatus = (data: IupdateFactoryStatus) => {
    return instacne.post(`product/update/publishStatus?ids=${data.ids}&publishStatus=${data.showStatus}`)
}
//修改新品状态product/update/newStatus批量设为新品
const UpdatenewStatus = (data: IupdateFactoryStatus) => {
    return instacne.post(`product/update/newStatus?ids=${data.ids}&newStatus=${data.showStatus}`)
}
//product/update/recommendStatus批量推荐商品
const UpdaterecommendStatus = (data: IupdateFactoryStatus) => {
    return instacne.post(`product/update/recommendStatus?ids=${data.ids}&recommendStatus=${data.showStatus}`)
}
//productCategory/{id}根据id获取商品分类
const productCategory = (data: string | string[]): Promise<IPromisproductCategory> => {
    return instacne.get(`productCategory/${data}`)
}
//brand/create添加品牌
const addCreate = (data: IAddCreateParams) => {
    return instacne.post(`brand/create`, data)
}
//brand/{id}根据编号查询品牌信息
const productBrand = (data: string | string[]): Promise<IBrandPromies> => {
    return instacne.get(`brand/${data}`)
}
//product/create创建商品
const productCreate = (data: any) => {
    return instacne.post(`product/create`,data)
}
/**
 *  属性类型  /productAttribute/category/list
 */
const attrCategory = (data: IBrandListParams): Promise<IBrandListRes> => {
    return instacne.get("/productAttribute/category/list", { params: data });
  };
export {
    GoodsfenleiList, GoodsBrandList, GoodscategoryList, GoodswithAttrList,
    GoodsDletefenleiList, GoodsDleteBrandList, GoodsDletecategoryList, GoodswithChildrenList
    , updatenavStatus, updatenavShowStatus, addproductCategory, updateFactoryStatus,
    brandupdateshowStatus, ProductList, DeleteProduct, UpdatePublishStatus, UpdatenewStatus,
    UpdaterecommendStatus, productCategory, updateproductCategory, updateBrand, addCreate, productBrand
    ,productCreate,attrCategory
}
export type { IGoodsListParams, IProductListParams,IBrandListItem }

// 获取商品列表数据


